package ink.ykb.j2CacheDemo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import ink.ykb.j2CacheDemo.interceptors.LoginInterceptor;
import ink.ykb.j2CacheDemo.util.HttpRequestLocal;


@Configuration
public class MvcConfig implements WebMvcConfigurer{

	@Autowired
	private HttpRequestLocal httpRequestLocal;

	/**
	 *	拦截器
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		
		registry.addInterceptor(new LoginInterceptor(httpRequestLocal))
			.addPathPatterns("/**")
			.excludePathPatterns("/login","/error",
					"/swagger-resources/**",
					"/test/**",
					"/static/**"
					);
		
	}

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
	}


	
}
